<?php
    include ('functions.php');
    session_start();
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>THE SHOP :: purchasing</title><link rel="stylesheet" type="text/css" href="style.css"/></head><body><div id="logo"><a href="index.php"><img src="img/logo.PNG" alt="THE SHOP"/></a></div>
<div id="main">
 
 <table width="100%" cellspacing="0" cellpadding="0">
    <tr><td id="mainpart"> <div id="menutable">
    <table width="95%" border="0">
      <tr>
        <td><p id="menu"><span><a href="index.php">Main page</a></span> :: <a href="products.php">Product list</a> :: <a href="faq.php">FAQ</a> :: <a href="info.php">About</a> :: <a href="cart.php" id="selected">Shopping cart</a></p></td>
        <td><form action="search.php" method="post" id="searchfield">
          <input name="search" type="text" value="Search now!" size="20" maxlength="100" onClick="this.value=''" />
          <input name="submit" type="submit" value="Search" />
        </form></td>
      </tr>
    </table>
  </div>
        <!-- MAIN PART -->
        <table id="layouttable"><tr><td>
           <?
            $sqlconnect=mysql_connect('localhost', 'root', 'kissakala');
            $dbselect=mysql_select_db('theshop', $sqlconnect);
            if($sqlconnect and $dbselect) {
                $gender = $_SESSION[gender];
                $fname = $_SESSION[fname];
                $sname = $_SESSION[sname];
                $address = $_SESSION[address];
                $postalCode = $_SESSION[postalcode];
                $town = $_SESSION[town];
                $country = $_SESSION[country];
                $purchases = $_SESSION[purchases];
                $sqladd="INSERT INTO purchases (gender, firstName, lastName, address, postalCode, postalOffice, country, purchases) VALUES ('$gender', ' $fname', '$sname', '$address', '$postalCode', '$town', '$country', '$purchases')";
                if(mysql_query($sqladd, $sqlconnect)) {
                    echo "Your purchase was stored in the database! <a href=\"index.php\">To the main page</a>.";
                }
                else {
                    echo "There was an error related to the database. Please contact the administration via e-mail. Thank you.";
                }
                mysql_close($sqlconnect);
            }

            ?>
        <!-- END OF MAIN PART -->
        </td></tr></table>
        </td>
    </tr>
  </table>
        <? putFooter();
        ?>
</div>

</body></html>